
/*
'===============================================================================
'  Generated From - CSharp_dOOdads_BusinessEntity.vbgen
' 
'  ** IMPORTANT  ** 
'  How to Generate your stored procedures:
' 
'  SQL        = SQL_StoredProcs.vbgen
'  ACCESS     = Access_StoredProcs.vbgen
'  ORACLE     = Oracle_StoredProcs.vbgen
'  FIREBIRD   = FirebirdStoredProcs.vbgen
'  POSTGRESQL = PostgreSQL_StoredProcs.vbgen
'
'  The supporting base class SqlClientEntity is in the Architecture directory in "dOOdads".
'  
'  This object is 'abstract' which means you need to inherit from it to be able
'  to instantiate it.  This is very easilly done. You can override properties and
'  methods in your derived class, this allows you to regenerate this class at any
'  time and not worry about overwriting custom code. 
'
'  NEVER EDIT THIS FILE.
'
'  public class YourObject :  _YourObject
'  {
'
'  }
'
'===============================================================================
*/

// Generated by MyGeneration Version # (1.3.0.3)

using System;
using System.Data;
using System.Data.SqlClient;
using System.Collections;
using System.Collections.Specialized;

using MyGeneration.dOOdads;

namespace POSSystem.DAL
{
	public abstract class _InvoiceDetails : SqlClientEntity
	{
		public _InvoiceDetails()
		{
			this.QuerySource = "InvoiceDetails";
			this.MappingName = "InvoiceDetails";

		}	

		//=================================================================
		//  public Overrides void AddNew()
		//=================================================================
		//
		//=================================================================
		public override void AddNew()
		{
			base.AddNew();
			
		}
		
		
		public override void FlushData()
		{
			this._whereClause = null;
			this._aggregateClause = null;
			base.FlushData();
		}
		
		//=================================================================
		//  	public Function LoadAll() As Boolean
		//=================================================================
		//  Loads all of the records in the database, and sets the currentRow to the first row
		//=================================================================
		public bool LoadAll() 
		{
			ListDictionary parameters = null;
			
			return base.LoadFromSql("[" + this.SchemaStoredProcedure + "proc_InvoiceDetailsLoadAll]", parameters);
		}
	
		//=================================================================
		// public Overridable Function LoadByPrimaryKey()  As Boolean
		//=================================================================
		//  Loads a single row of via the primary key
		//=================================================================
		public virtual bool LoadByPrimaryKey(int ID)
		{
			ListDictionary parameters = new ListDictionary();
			parameters.Add(Parameters.ID, ID);

		
			return base.LoadFromSql("[" + this.SchemaStoredProcedure + "proc_InvoiceDetailsLoadByPrimaryKey]", parameters);
		}
		
		#region Parameters
		protected class Parameters
		{
			
			public static SqlParameter ID
			{
				get
				{
					return new SqlParameter("@ID", SqlDbType.Int, 0);
				}
			}
			
			public static SqlParameter InvoiceID
			{
				get
				{
					return new SqlParameter("@InvoiceID", SqlDbType.Int, 0);
				}
			}
			
			public static SqlParameter ProductID
			{
				get
				{
					return new SqlParameter("@ProductID", SqlDbType.Int, 0);
				}
			}
			
			public static SqlParameter IMEI
			{
				get
				{
					return new SqlParameter("@IMEI", SqlDbType.NVarChar, 20);
				}
			}
			
			public static SqlParameter Description
			{
				get
				{
					return new SqlParameter("@Description", SqlDbType.NVarChar, 1000);
				}
			}
			
			public static SqlParameter Quantity
			{
				get
				{
					return new SqlParameter("@Quantity", SqlDbType.Int, 0);
				}
			}
			
			public static SqlParameter GST
			{
				get
				{
					return new SqlParameter("@GST", SqlDbType.Decimal, 0);
				}
			}
			
			public static SqlParameter UnitPrice
			{
				get
				{
					return new SqlParameter("@UnitPrice", SqlDbType.Decimal, 0);
				}
			}
			
			public static SqlParameter Cost
			{
				get
				{
					return new SqlParameter("@Cost", SqlDbType.Decimal, 0);
				}
			}
			
			public static SqlParameter Deleted
			{
				get
				{
					return new SqlParameter("@Deleted", SqlDbType.Bit, 0);
				}
			}
			
			public static SqlParameter LastModifiedDate
			{
				get
				{
					return new SqlParameter("@LastModifiedDate", SqlDbType.DateTime, 0);
				}
			}
			
			public static SqlParameter LastModifiedByUser
			{
				get
				{
					return new SqlParameter("@LastModifiedByUser", SqlDbType.Int, 0);
				}
			}
			
			public static SqlParameter Discount
			{
				get
				{
					return new SqlParameter("@Discount", SqlDbType.Decimal, 0);
				}
			}
			
			public static SqlParameter ItemType
			{
				get
				{
					return new SqlParameter("@ItemType", SqlDbType.TinyInt, 0);
				}
			}
			
			public static SqlParameter BranchID
			{
				get
				{
					return new SqlParameter("@BranchID", SqlDbType.Int, 0);
				}
			}
			
		}
		#endregion		
	
		#region ColumnNames
		public class ColumnNames
		{  
            public const string ID = "ID";
            public const string InvoiceID = "InvoiceID";
            public const string ProductID = "ProductID";
            public const string IMEI = "IMEI";
            public const string Description = "Description";
            public const string Quantity = "Quantity";
            public const string GST = "GST";
            public const string UnitPrice = "UnitPrice";
            public const string Cost = "Cost";
            public const string Deleted = "Deleted";
            public const string LastModifiedDate = "LastModifiedDate";
            public const string LastModifiedByUser = "LastModifiedByUser";
            public const string Discount = "Discount";
            public const string ItemType = "ItemType";
            public const string BranchID = "BranchID";

			static public string ToPropertyName(string columnName)
			{
				if(ht == null)
				{
					ht = new Hashtable();
					
					ht[ID] = _InvoiceDetails.PropertyNames.ID;
					ht[InvoiceID] = _InvoiceDetails.PropertyNames.InvoiceID;
					ht[ProductID] = _InvoiceDetails.PropertyNames.ProductID;
					ht[IMEI] = _InvoiceDetails.PropertyNames.IMEI;
					ht[Description] = _InvoiceDetails.PropertyNames.Description;
					ht[Quantity] = _InvoiceDetails.PropertyNames.Quantity;
					ht[GST] = _InvoiceDetails.PropertyNames.GST;
					ht[UnitPrice] = _InvoiceDetails.PropertyNames.UnitPrice;
					ht[Cost] = _InvoiceDetails.PropertyNames.Cost;
					ht[Deleted] = _InvoiceDetails.PropertyNames.Deleted;
					ht[LastModifiedDate] = _InvoiceDetails.PropertyNames.LastModifiedDate;
					ht[LastModifiedByUser] = _InvoiceDetails.PropertyNames.LastModifiedByUser;
					ht[Discount] = _InvoiceDetails.PropertyNames.Discount;
					ht[ItemType] = _InvoiceDetails.PropertyNames.ItemType;
					ht[BranchID] = _InvoiceDetails.PropertyNames.BranchID;

				}
				return (string)ht[columnName];
			}

			static private Hashtable ht = null;			 
		}
		#endregion
		
		#region PropertyNames
		public class PropertyNames
		{  
            public const string ID = "ID";
            public const string InvoiceID = "InvoiceID";
            public const string ProductID = "ProductID";
            public const string IMEI = "IMEI";
            public const string Description = "Description";
            public const string Quantity = "Quantity";
            public const string GST = "GST";
            public const string UnitPrice = "UnitPrice";
            public const string Cost = "Cost";
            public const string Deleted = "Deleted";
            public const string LastModifiedDate = "LastModifiedDate";
            public const string LastModifiedByUser = "LastModifiedByUser";
            public const string Discount = "Discount";
            public const string ItemType = "ItemType";
            public const string BranchID = "BranchID";

			static public string ToColumnName(string propertyName)
			{
				if(ht == null)
				{
					ht = new Hashtable();
					
					ht[ID] = _InvoiceDetails.ColumnNames.ID;
					ht[InvoiceID] = _InvoiceDetails.ColumnNames.InvoiceID;
					ht[ProductID] = _InvoiceDetails.ColumnNames.ProductID;
					ht[IMEI] = _InvoiceDetails.ColumnNames.IMEI;
					ht[Description] = _InvoiceDetails.ColumnNames.Description;
					ht[Quantity] = _InvoiceDetails.ColumnNames.Quantity;
					ht[GST] = _InvoiceDetails.ColumnNames.GST;
					ht[UnitPrice] = _InvoiceDetails.ColumnNames.UnitPrice;
					ht[Cost] = _InvoiceDetails.ColumnNames.Cost;
					ht[Deleted] = _InvoiceDetails.ColumnNames.Deleted;
					ht[LastModifiedDate] = _InvoiceDetails.ColumnNames.LastModifiedDate;
					ht[LastModifiedByUser] = _InvoiceDetails.ColumnNames.LastModifiedByUser;
					ht[Discount] = _InvoiceDetails.ColumnNames.Discount;
					ht[ItemType] = _InvoiceDetails.ColumnNames.ItemType;
					ht[BranchID] = _InvoiceDetails.ColumnNames.BranchID;

				}
				return (string)ht[propertyName];
			}

			static private Hashtable ht = null;			 
		}			 
		#endregion	

		#region StringPropertyNames
		public class StringPropertyNames
		{  
            public const string ID = "s_ID";
            public const string InvoiceID = "s_InvoiceID";
            public const string ProductID = "s_ProductID";
            public const string IMEI = "s_IMEI";
            public const string Description = "s_Description";
            public const string Quantity = "s_Quantity";
            public const string GST = "s_GST";
            public const string UnitPrice = "s_UnitPrice";
            public const string Cost = "s_Cost";
            public const string Deleted = "s_Deleted";
            public const string LastModifiedDate = "s_LastModifiedDate";
            public const string LastModifiedByUser = "s_LastModifiedByUser";
            public const string Discount = "s_Discount";
            public const string ItemType = "s_ItemType";
            public const string BranchID = "s_BranchID";

		}
		#endregion		
		
		#region Properties
	
		public virtual int ID
	    {
			get
	        {
				return base.Getint(ColumnNames.ID);
			}
			set
	        {
				base.Setint(ColumnNames.ID, value);
			}
		}

		public virtual int InvoiceID
	    {
			get
	        {
				return base.Getint(ColumnNames.InvoiceID);
			}
			set
	        {
				base.Setint(ColumnNames.InvoiceID, value);
			}
		}

		public virtual int ProductID
	    {
			get
	        {
				return base.Getint(ColumnNames.ProductID);
			}
			set
	        {
				base.Setint(ColumnNames.ProductID, value);
			}
		}

		public virtual string IMEI
	    {
			get
	        {
				return base.Getstring(ColumnNames.IMEI);
			}
			set
	        {
				base.Setstring(ColumnNames.IMEI, value);
			}
		}

		public virtual string Description
	    {
			get
	        {
				return base.Getstring(ColumnNames.Description);
			}
			set
	        {
				base.Setstring(ColumnNames.Description, value);
			}
		}

		public virtual int Quantity
	    {
			get
	        {
				return base.Getint(ColumnNames.Quantity);
			}
			set
	        {
				base.Setint(ColumnNames.Quantity, value);
			}
		}

		public virtual decimal GST
	    {
			get
	        {
				return base.Getdecimal(ColumnNames.GST);
			}
			set
	        {
				base.Setdecimal(ColumnNames.GST, value);
			}
		}

		public virtual decimal UnitPrice
	    {
			get
	        {
				return base.Getdecimal(ColumnNames.UnitPrice);
			}
			set
	        {
				base.Setdecimal(ColumnNames.UnitPrice, value);
			}
		}

		public virtual decimal Cost
	    {
			get
	        {
				return base.Getdecimal(ColumnNames.Cost);
			}
			set
	        {
				base.Setdecimal(ColumnNames.Cost, value);
			}
		}

		public virtual bool Deleted
	    {
			get
	        {
				return base.Getbool(ColumnNames.Deleted);
			}
			set
	        {
				base.Setbool(ColumnNames.Deleted, value);
			}
		}

		public virtual DateTime LastModifiedDate
	    {
			get
	        {
				return base.GetDateTime(ColumnNames.LastModifiedDate);
			}
			set
	        {
				base.SetDateTime(ColumnNames.LastModifiedDate, value);
			}
		}

		public virtual int LastModifiedByUser
	    {
			get
	        {
				return base.Getint(ColumnNames.LastModifiedByUser);
			}
			set
	        {
				base.Setint(ColumnNames.LastModifiedByUser, value);
			}
		}

		public virtual decimal Discount
	    {
			get
	        {
				return base.Getdecimal(ColumnNames.Discount);
			}
			set
	        {
				base.Setdecimal(ColumnNames.Discount, value);
			}
		}

		public virtual byte ItemType
	    {
			get
	        {
				return base.Getbyte(ColumnNames.ItemType);
			}
			set
	        {
				base.Setbyte(ColumnNames.ItemType, value);
			}
		}

		public virtual int BranchID
	    {
			get
	        {
				return base.Getint(ColumnNames.BranchID);
			}
			set
	        {
				base.Setint(ColumnNames.BranchID, value);
			}
		}


		#endregion
		
		#region String Properties
	
		public virtual string s_ID
	    {
			get
	        {
				return this.IsColumnNull(ColumnNames.ID) ? string.Empty : base.GetintAsString(ColumnNames.ID);
			}
			set
	        {
				if(string.Empty == value)
					this.SetColumnNull(ColumnNames.ID);
				else
					this.ID = base.SetintAsString(ColumnNames.ID, value);
			}
		}

		public virtual string s_InvoiceID
	    {
			get
	        {
				return this.IsColumnNull(ColumnNames.InvoiceID) ? string.Empty : base.GetintAsString(ColumnNames.InvoiceID);
			}
			set
	        {
				if(string.Empty == value)
					this.SetColumnNull(ColumnNames.InvoiceID);
				else
					this.InvoiceID = base.SetintAsString(ColumnNames.InvoiceID, value);
			}
		}

		public virtual string s_ProductID
	    {
			get
	        {
				return this.IsColumnNull(ColumnNames.ProductID) ? string.Empty : base.GetintAsString(ColumnNames.ProductID);
			}
			set
	        {
				if(string.Empty == value)
					this.SetColumnNull(ColumnNames.ProductID);
				else
					this.ProductID = base.SetintAsString(ColumnNames.ProductID, value);
			}
		}

		public virtual string s_IMEI
	    {
			get
	        {
				return this.IsColumnNull(ColumnNames.IMEI) ? string.Empty : base.GetstringAsString(ColumnNames.IMEI);
			}
			set
	        {
				if(string.Empty == value)
					this.SetColumnNull(ColumnNames.IMEI);
				else
					this.IMEI = base.SetstringAsString(ColumnNames.IMEI, value);
			}
		}

		public virtual string s_Description
	    {
			get
	        {
				return this.IsColumnNull(ColumnNames.Description) ? string.Empty : base.GetstringAsString(ColumnNames.Description);
			}
			set
	        {
				if(string.Empty == value)
					this.SetColumnNull(ColumnNames.Description);
				else
					this.Description = base.SetstringAsString(ColumnNames.Description, value);
			}
		}

		public virtual string s_Quantity
	    {
			get
	        {
				return this.IsColumnNull(ColumnNames.Quantity) ? string.Empty : base.GetintAsString(ColumnNames.Quantity);
			}
			set
	        {
				if(string.Empty == value)
					this.SetColumnNull(ColumnNames.Quantity);
				else
					this.Quantity = base.SetintAsString(ColumnNames.Quantity, value);
			}
		}

		public virtual string s_GST
	    {
			get
	        {
				return this.IsColumnNull(ColumnNames.GST) ? string.Empty : base.GetdecimalAsString(ColumnNames.GST);
			}
			set
	        {
				if(string.Empty == value)
					this.SetColumnNull(ColumnNames.GST);
				else
					this.GST = base.SetdecimalAsString(ColumnNames.GST, value);
			}
		}

		public virtual string s_UnitPrice
	    {
			get
	        {
				return this.IsColumnNull(ColumnNames.UnitPrice) ? string.Empty : base.GetdecimalAsString(ColumnNames.UnitPrice);
			}
			set
	        {
				if(string.Empty == value)
					this.SetColumnNull(ColumnNames.UnitPrice);
				else
					this.UnitPrice = base.SetdecimalAsString(ColumnNames.UnitPrice, value);
			}
		}

		public virtual string s_Cost
	    {
			get
	        {
				return this.IsColumnNull(ColumnNames.Cost) ? string.Empty : base.GetdecimalAsString(ColumnNames.Cost);
			}
			set
	        {
				if(string.Empty == value)
					this.SetColumnNull(ColumnNames.Cost);
				else
					this.Cost = base.SetdecimalAsString(ColumnNames.Cost, value);
			}
		}

		public virtual string s_Deleted
	    {
			get
	        {
				return this.IsColumnNull(ColumnNames.Deleted) ? string.Empty : base.GetboolAsString(ColumnNames.Deleted);
			}
			set
	        {
				if(string.Empty == value)
					this.SetColumnNull(ColumnNames.Deleted);
				else
					this.Deleted = base.SetboolAsString(ColumnNames.Deleted, value);
			}
		}

		public virtual string s_LastModifiedDate
	    {
			get
	        {
				return this.IsColumnNull(ColumnNames.LastModifiedDate) ? string.Empty : base.GetDateTimeAsString(ColumnNames.LastModifiedDate);
			}
			set
	        {
				if(string.Empty == value)
					this.SetColumnNull(ColumnNames.LastModifiedDate);
				else
					this.LastModifiedDate = base.SetDateTimeAsString(ColumnNames.LastModifiedDate, value);
			}
		}

		public virtual string s_LastModifiedByUser
	    {
			get
	        {
				return this.IsColumnNull(ColumnNames.LastModifiedByUser) ? string.Empty : base.GetintAsString(ColumnNames.LastModifiedByUser);
			}
			set
	        {
				if(string.Empty == value)
					this.SetColumnNull(ColumnNames.LastModifiedByUser);
				else
					this.LastModifiedByUser = base.SetintAsString(ColumnNames.LastModifiedByUser, value);
			}
		}

		public virtual string s_Discount
	    {
			get
	        {
				return this.IsColumnNull(ColumnNames.Discount) ? string.Empty : base.GetdecimalAsString(ColumnNames.Discount);
			}
			set
	        {
				if(string.Empty == value)
					this.SetColumnNull(ColumnNames.Discount);
				else
					this.Discount = base.SetdecimalAsString(ColumnNames.Discount, value);
			}
		}

		public virtual string s_ItemType
	    {
			get
	        {
				return this.IsColumnNull(ColumnNames.ItemType) ? string.Empty : base.GetbyteAsString(ColumnNames.ItemType);
			}
			set
	        {
				if(string.Empty == value)
					this.SetColumnNull(ColumnNames.ItemType);
				else
					this.ItemType = base.SetbyteAsString(ColumnNames.ItemType, value);
			}
		}

		public virtual string s_BranchID
	    {
			get
	        {
				return this.IsColumnNull(ColumnNames.BranchID) ? string.Empty : base.GetintAsString(ColumnNames.BranchID);
			}
			set
	        {
				if(string.Empty == value)
					this.SetColumnNull(ColumnNames.BranchID);
				else
					this.BranchID = base.SetintAsString(ColumnNames.BranchID, value);
			}
		}


		#endregion		
	
		#region Where Clause
		public class WhereClause
		{
			public WhereClause(BusinessEntity entity)
			{
				this._entity = entity;
			}
			
			public TearOffWhereParameter TearOff
			{
				get
				{
					if(_tearOff == null)
					{
						_tearOff = new TearOffWhereParameter(this);
					}

					return _tearOff;
				}
			}

			#region WhereParameter TearOff's
			public class TearOffWhereParameter
			{
				public TearOffWhereParameter(WhereClause clause)
				{
					this._clause = clause;
				}
				
				
				public WhereParameter ID
				{
					get
					{
							WhereParameter where = new WhereParameter(ColumnNames.ID, Parameters.ID);
							this._clause._entity.Query.AddWhereParameter(where);
							return where;
					}
				}

				public WhereParameter InvoiceID
				{
					get
					{
							WhereParameter where = new WhereParameter(ColumnNames.InvoiceID, Parameters.InvoiceID);
							this._clause._entity.Query.AddWhereParameter(where);
							return where;
					}
				}

				public WhereParameter ProductID
				{
					get
					{
							WhereParameter where = new WhereParameter(ColumnNames.ProductID, Parameters.ProductID);
							this._clause._entity.Query.AddWhereParameter(where);
							return where;
					}
				}

				public WhereParameter IMEI
				{
					get
					{
							WhereParameter where = new WhereParameter(ColumnNames.IMEI, Parameters.IMEI);
							this._clause._entity.Query.AddWhereParameter(where);
							return where;
					}
				}

				public WhereParameter Description
				{
					get
					{
							WhereParameter where = new WhereParameter(ColumnNames.Description, Parameters.Description);
							this._clause._entity.Query.AddWhereParameter(where);
							return where;
					}
				}

				public WhereParameter Quantity
				{
					get
					{
							WhereParameter where = new WhereParameter(ColumnNames.Quantity, Parameters.Quantity);
							this._clause._entity.Query.AddWhereParameter(where);
							return where;
					}
				}

				public WhereParameter GST
				{
					get
					{
							WhereParameter where = new WhereParameter(ColumnNames.GST, Parameters.GST);
							this._clause._entity.Query.AddWhereParameter(where);
							return where;
					}
				}

				public WhereParameter UnitPrice
				{
					get
					{
							WhereParameter where = new WhereParameter(ColumnNames.UnitPrice, Parameters.UnitPrice);
							this._clause._entity.Query.AddWhereParameter(where);
							return where;
					}
				}

				public WhereParameter Cost
				{
					get
					{
							WhereParameter where = new WhereParameter(ColumnNames.Cost, Parameters.Cost);
							this._clause._entity.Query.AddWhereParameter(where);
							return where;
					}
				}

				public WhereParameter Deleted
				{
					get
					{
							WhereParameter where = new WhereParameter(ColumnNames.Deleted, Parameters.Deleted);
							this._clause._entity.Query.AddWhereParameter(where);
							return where;
					}
				}

				public WhereParameter LastModifiedDate
				{
					get
					{
							WhereParameter where = new WhereParameter(ColumnNames.LastModifiedDate, Parameters.LastModifiedDate);
							this._clause._entity.Query.AddWhereParameter(where);
							return where;
					}
				}

				public WhereParameter LastModifiedByUser
				{
					get
					{
							WhereParameter where = new WhereParameter(ColumnNames.LastModifiedByUser, Parameters.LastModifiedByUser);
							this._clause._entity.Query.AddWhereParameter(where);
							return where;
					}
				}

				public WhereParameter Discount
				{
					get
					{
							WhereParameter where = new WhereParameter(ColumnNames.Discount, Parameters.Discount);
							this._clause._entity.Query.AddWhereParameter(where);
							return where;
					}
				}

				public WhereParameter ItemType
				{
					get
					{
							WhereParameter where = new WhereParameter(ColumnNames.ItemType, Parameters.ItemType);
							this._clause._entity.Query.AddWhereParameter(where);
							return where;
					}
				}

				public WhereParameter BranchID
				{
					get
					{
							WhereParameter where = new WhereParameter(ColumnNames.BranchID, Parameters.BranchID);
							this._clause._entity.Query.AddWhereParameter(where);
							return where;
					}
				}


				private WhereClause _clause;
			}
			#endregion
		
			public WhereParameter ID
		    {
				get
		        {
					if(_ID_W == null)
	        	    {
						_ID_W = TearOff.ID;
					}
					return _ID_W;
				}
			}

			public WhereParameter InvoiceID
		    {
				get
		        {
					if(_InvoiceID_W == null)
	        	    {
						_InvoiceID_W = TearOff.InvoiceID;
					}
					return _InvoiceID_W;
				}
			}

			public WhereParameter ProductID
		    {
				get
		        {
					if(_ProductID_W == null)
	        	    {
						_ProductID_W = TearOff.ProductID;
					}
					return _ProductID_W;
				}
			}

			public WhereParameter IMEI
		    {
				get
		        {
					if(_IMEI_W == null)
	        	    {
						_IMEI_W = TearOff.IMEI;
					}
					return _IMEI_W;
				}
			}

			public WhereParameter Description
		    {
				get
		        {
					if(_Description_W == null)
	        	    {
						_Description_W = TearOff.Description;
					}
					return _Description_W;
				}
			}

			public WhereParameter Quantity
		    {
				get
		        {
					if(_Quantity_W == null)
	        	    {
						_Quantity_W = TearOff.Quantity;
					}
					return _Quantity_W;
				}
			}

			public WhereParameter GST
		    {
				get
		        {
					if(_GST_W == null)
	        	    {
						_GST_W = TearOff.GST;
					}
					return _GST_W;
				}
			}

			public WhereParameter UnitPrice
		    {
				get
		        {
					if(_UnitPrice_W == null)
	        	    {
						_UnitPrice_W = TearOff.UnitPrice;
					}
					return _UnitPrice_W;
				}
			}

			public WhereParameter Cost
		    {
				get
		        {
					if(_Cost_W == null)
	        	    {
						_Cost_W = TearOff.Cost;
					}
					return _Cost_W;
				}
			}

			public WhereParameter Deleted
		    {
				get
		        {
					if(_Deleted_W == null)
	        	    {
						_Deleted_W = TearOff.Deleted;
					}
					return _Deleted_W;
				}
			}

			public WhereParameter LastModifiedDate
		    {
				get
		        {
					if(_LastModifiedDate_W == null)
	        	    {
						_LastModifiedDate_W = TearOff.LastModifiedDate;
					}
					return _LastModifiedDate_W;
				}
			}

			public WhereParameter LastModifiedByUser
		    {
				get
		        {
					if(_LastModifiedByUser_W == null)
	        	    {
						_LastModifiedByUser_W = TearOff.LastModifiedByUser;
					}
					return _LastModifiedByUser_W;
				}
			}

			public WhereParameter Discount
		    {
				get
		        {
					if(_Discount_W == null)
	        	    {
						_Discount_W = TearOff.Discount;
					}
					return _Discount_W;
				}
			}

			public WhereParameter ItemType
		    {
				get
		        {
					if(_ItemType_W == null)
	        	    {
						_ItemType_W = TearOff.ItemType;
					}
					return _ItemType_W;
				}
			}

			public WhereParameter BranchID
		    {
				get
		        {
					if(_BranchID_W == null)
	        	    {
						_BranchID_W = TearOff.BranchID;
					}
					return _BranchID_W;
				}
			}

			private WhereParameter _ID_W = null;
			private WhereParameter _InvoiceID_W = null;
			private WhereParameter _ProductID_W = null;
			private WhereParameter _IMEI_W = null;
			private WhereParameter _Description_W = null;
			private WhereParameter _Quantity_W = null;
			private WhereParameter _GST_W = null;
			private WhereParameter _UnitPrice_W = null;
			private WhereParameter _Cost_W = null;
			private WhereParameter _Deleted_W = null;
			private WhereParameter _LastModifiedDate_W = null;
			private WhereParameter _LastModifiedByUser_W = null;
			private WhereParameter _Discount_W = null;
			private WhereParameter _ItemType_W = null;
			private WhereParameter _BranchID_W = null;

			public void WhereClauseReset()
			{
				_ID_W = null;
				_InvoiceID_W = null;
				_ProductID_W = null;
				_IMEI_W = null;
				_Description_W = null;
				_Quantity_W = null;
				_GST_W = null;
				_UnitPrice_W = null;
				_Cost_W = null;
				_Deleted_W = null;
				_LastModifiedDate_W = null;
				_LastModifiedByUser_W = null;
				_Discount_W = null;
				_ItemType_W = null;
				_BranchID_W = null;

				this._entity.Query.FlushWhereParameters();

			}
	
			private BusinessEntity _entity;
			private TearOffWhereParameter _tearOff;
			
		}
	
		public WhereClause Where
		{
			get
			{
				if(_whereClause == null)
				{
					_whereClause = new WhereClause(this);
				}
		
				return _whereClause;
			}
		}
		
		private WhereClause _whereClause = null;	
		#endregion
	
		#region Aggregate Clause
		public class AggregateClause
		{
			public AggregateClause(BusinessEntity entity)
			{
				this._entity = entity;
			}
			
			public TearOffAggregateParameter TearOff
			{
				get
				{
					if(_tearOff == null)
					{
						_tearOff = new TearOffAggregateParameter(this);
					}

					return _tearOff;
				}
			}

			#region AggregateParameter TearOff's
			public class TearOffAggregateParameter
			{
				public TearOffAggregateParameter(AggregateClause clause)
				{
					this._clause = clause;
				}
				
				
				public AggregateParameter ID
				{
					get
					{
							AggregateParameter aggregate = new AggregateParameter(ColumnNames.ID, Parameters.ID);
							this._clause._entity.Query.AddAggregateParameter(aggregate);
							return aggregate;
					}
				}

				public AggregateParameter InvoiceID
				{
					get
					{
							AggregateParameter aggregate = new AggregateParameter(ColumnNames.InvoiceID, Parameters.InvoiceID);
							this._clause._entity.Query.AddAggregateParameter(aggregate);
							return aggregate;
					}
				}

				public AggregateParameter ProductID
				{
					get
					{
							AggregateParameter aggregate = new AggregateParameter(ColumnNames.ProductID, Parameters.ProductID);
							this._clause._entity.Query.AddAggregateParameter(aggregate);
							return aggregate;
					}
				}

				public AggregateParameter IMEI
				{
					get
					{
							AggregateParameter aggregate = new AggregateParameter(ColumnNames.IMEI, Parameters.IMEI);
							this._clause._entity.Query.AddAggregateParameter(aggregate);
							return aggregate;
					}
				}

				public AggregateParameter Description
				{
					get
					{
							AggregateParameter aggregate = new AggregateParameter(ColumnNames.Description, Parameters.Description);
							this._clause._entity.Query.AddAggregateParameter(aggregate);
							return aggregate;
					}
				}

				public AggregateParameter Quantity
				{
					get
					{
							AggregateParameter aggregate = new AggregateParameter(ColumnNames.Quantity, Parameters.Quantity);
							this._clause._entity.Query.AddAggregateParameter(aggregate);
							return aggregate;
					}
				}

				public AggregateParameter GST
				{
					get
					{
							AggregateParameter aggregate = new AggregateParameter(ColumnNames.GST, Parameters.GST);
							this._clause._entity.Query.AddAggregateParameter(aggregate);
							return aggregate;
					}
				}

				public AggregateParameter UnitPrice
				{
					get
					{
							AggregateParameter aggregate = new AggregateParameter(ColumnNames.UnitPrice, Parameters.UnitPrice);
							this._clause._entity.Query.AddAggregateParameter(aggregate);
							return aggregate;
					}
				}

				public AggregateParameter Cost
				{
					get
					{
							AggregateParameter aggregate = new AggregateParameter(ColumnNames.Cost, Parameters.Cost);
							this._clause._entity.Query.AddAggregateParameter(aggregate);
							return aggregate;
					}
				}

				public AggregateParameter Deleted
				{
					get
					{
							AggregateParameter aggregate = new AggregateParameter(ColumnNames.Deleted, Parameters.Deleted);
							this._clause._entity.Query.AddAggregateParameter(aggregate);
							return aggregate;
					}
				}

				public AggregateParameter LastModifiedDate
				{
					get
					{
							AggregateParameter aggregate = new AggregateParameter(ColumnNames.LastModifiedDate, Parameters.LastModifiedDate);
							this._clause._entity.Query.AddAggregateParameter(aggregate);
							return aggregate;
					}
				}

				public AggregateParameter LastModifiedByUser
				{
					get
					{
							AggregateParameter aggregate = new AggregateParameter(ColumnNames.LastModifiedByUser, Parameters.LastModifiedByUser);
							this._clause._entity.Query.AddAggregateParameter(aggregate);
							return aggregate;
					}
				}

				public AggregateParameter Discount
				{
					get
					{
							AggregateParameter aggregate = new AggregateParameter(ColumnNames.Discount, Parameters.Discount);
							this._clause._entity.Query.AddAggregateParameter(aggregate);
							return aggregate;
					}
				}

				public AggregateParameter ItemType
				{
					get
					{
							AggregateParameter aggregate = new AggregateParameter(ColumnNames.ItemType, Parameters.ItemType);
							this._clause._entity.Query.AddAggregateParameter(aggregate);
							return aggregate;
					}
				}

				public AggregateParameter BranchID
				{
					get
					{
							AggregateParameter aggregate = new AggregateParameter(ColumnNames.BranchID, Parameters.BranchID);
							this._clause._entity.Query.AddAggregateParameter(aggregate);
							return aggregate;
					}
				}


				private AggregateClause _clause;
			}
			#endregion
		
			public AggregateParameter ID
		    {
				get
		        {
					if(_ID_W == null)
	        	    {
						_ID_W = TearOff.ID;
					}
					return _ID_W;
				}
			}

			public AggregateParameter InvoiceID
		    {
				get
		        {
					if(_InvoiceID_W == null)
	        	    {
						_InvoiceID_W = TearOff.InvoiceID;
					}
					return _InvoiceID_W;
				}
			}

			public AggregateParameter ProductID
		    {
				get
		        {
					if(_ProductID_W == null)
	        	    {
						_ProductID_W = TearOff.ProductID;
					}
					return _ProductID_W;
				}
			}

			public AggregateParameter IMEI
		    {
				get
		        {
					if(_IMEI_W == null)
	        	    {
						_IMEI_W = TearOff.IMEI;
					}
					return _IMEI_W;
				}
			}

			public AggregateParameter Description
		    {
				get
		        {
					if(_Description_W == null)
	        	    {
						_Description_W = TearOff.Description;
					}
					return _Description_W;
				}
			}

			public AggregateParameter Quantity
		    {
				get
		        {
					if(_Quantity_W == null)
	        	    {
						_Quantity_W = TearOff.Quantity;
					}
					return _Quantity_W;
				}
			}

			public AggregateParameter GST
		    {
				get
		        {
					if(_GST_W == null)
	        	    {
						_GST_W = TearOff.GST;
					}
					return _GST_W;
				}
			}

			public AggregateParameter UnitPrice
		    {
				get
		        {
					if(_UnitPrice_W == null)
	        	    {
						_UnitPrice_W = TearOff.UnitPrice;
					}
					return _UnitPrice_W;
				}
			}

			public AggregateParameter Cost
		    {
				get
		        {
					if(_Cost_W == null)
	        	    {
						_Cost_W = TearOff.Cost;
					}
					return _Cost_W;
				}
			}

			public AggregateParameter Deleted
		    {
				get
		        {
					if(_Deleted_W == null)
	        	    {
						_Deleted_W = TearOff.Deleted;
					}
					return _Deleted_W;
				}
			}

			public AggregateParameter LastModifiedDate
		    {
				get
		        {
					if(_LastModifiedDate_W == null)
	        	    {
						_LastModifiedDate_W = TearOff.LastModifiedDate;
					}
					return _LastModifiedDate_W;
				}
			}

			public AggregateParameter LastModifiedByUser
		    {
				get
		        {
					if(_LastModifiedByUser_W == null)
	        	    {
						_LastModifiedByUser_W = TearOff.LastModifiedByUser;
					}
					return _LastModifiedByUser_W;
				}
			}

			public AggregateParameter Discount
		    {
				get
		        {
					if(_Discount_W == null)
	        	    {
						_Discount_W = TearOff.Discount;
					}
					return _Discount_W;
				}
			}

			public AggregateParameter ItemType
		    {
				get
		        {
					if(_ItemType_W == null)
	        	    {
						_ItemType_W = TearOff.ItemType;
					}
					return _ItemType_W;
				}
			}

			public AggregateParameter BranchID
		    {
				get
		        {
					if(_BranchID_W == null)
	        	    {
						_BranchID_W = TearOff.BranchID;
					}
					return _BranchID_W;
				}
			}

			private AggregateParameter _ID_W = null;
			private AggregateParameter _InvoiceID_W = null;
			private AggregateParameter _ProductID_W = null;
			private AggregateParameter _IMEI_W = null;
			private AggregateParameter _Description_W = null;
			private AggregateParameter _Quantity_W = null;
			private AggregateParameter _GST_W = null;
			private AggregateParameter _UnitPrice_W = null;
			private AggregateParameter _Cost_W = null;
			private AggregateParameter _Deleted_W = null;
			private AggregateParameter _LastModifiedDate_W = null;
			private AggregateParameter _LastModifiedByUser_W = null;
			private AggregateParameter _Discount_W = null;
			private AggregateParameter _ItemType_W = null;
			private AggregateParameter _BranchID_W = null;

			public void AggregateClauseReset()
			{
				_ID_W = null;
				_InvoiceID_W = null;
				_ProductID_W = null;
				_IMEI_W = null;
				_Description_W = null;
				_Quantity_W = null;
				_GST_W = null;
				_UnitPrice_W = null;
				_Cost_W = null;
				_Deleted_W = null;
				_LastModifiedDate_W = null;
				_LastModifiedByUser_W = null;
				_Discount_W = null;
				_ItemType_W = null;
				_BranchID_W = null;

				this._entity.Query.FlushAggregateParameters();

			}
	
			private BusinessEntity _entity;
			private TearOffAggregateParameter _tearOff;
			
		}
	
		public AggregateClause Aggregate
		{
			get
			{
				if(_aggregateClause == null)
				{
					_aggregateClause = new AggregateClause(this);
				}
		
				return _aggregateClause;
			}
		}
		
		private AggregateClause _aggregateClause = null;	
		#endregion
	
		protected override IDbCommand GetInsertCommand() 
		{
		
			SqlCommand cmd = new SqlCommand();
			cmd.CommandType = CommandType.StoredProcedure;
			cmd.CommandText = "[" + this.SchemaStoredProcedure + "proc_InvoiceDetailsInsert]";
	
			CreateParameters(cmd);
			
			SqlParameter p;
			p = cmd.Parameters[Parameters.ID.ParameterName];
			p.Direction = ParameterDirection.Output;
    
			return cmd;
		}
	
		protected override IDbCommand GetUpdateCommand()
		{
		
			SqlCommand cmd = new SqlCommand();
			cmd.CommandType = CommandType.StoredProcedure;
			cmd.CommandText = "[" + this.SchemaStoredProcedure + "proc_InvoiceDetailsUpdate]";
	
			CreateParameters(cmd);
			      
			return cmd;
		}
	
		protected override IDbCommand GetDeleteCommand()
		{
		
			SqlCommand cmd = new SqlCommand();
			cmd.CommandType = CommandType.StoredProcedure;
			cmd.CommandText = "[" + this.SchemaStoredProcedure + "proc_InvoiceDetailsDelete]";
	
			SqlParameter p;
			p = cmd.Parameters.Add(Parameters.ID);
			p.SourceColumn = ColumnNames.ID;
			p.SourceVersion = DataRowVersion.Current;

  
			return cmd;
		}
		
		private IDbCommand CreateParameters(SqlCommand cmd)
		{
			SqlParameter p;
		
			p = cmd.Parameters.Add(Parameters.ID);
			p.SourceColumn = ColumnNames.ID;
			p.SourceVersion = DataRowVersion.Current;

			p = cmd.Parameters.Add(Parameters.InvoiceID);
			p.SourceColumn = ColumnNames.InvoiceID;
			p.SourceVersion = DataRowVersion.Current;

			p = cmd.Parameters.Add(Parameters.ProductID);
			p.SourceColumn = ColumnNames.ProductID;
			p.SourceVersion = DataRowVersion.Current;

			p = cmd.Parameters.Add(Parameters.IMEI);
			p.SourceColumn = ColumnNames.IMEI;
			p.SourceVersion = DataRowVersion.Current;

			p = cmd.Parameters.Add(Parameters.Description);
			p.SourceColumn = ColumnNames.Description;
			p.SourceVersion = DataRowVersion.Current;

			p = cmd.Parameters.Add(Parameters.Quantity);
			p.SourceColumn = ColumnNames.Quantity;
			p.SourceVersion = DataRowVersion.Current;

			p = cmd.Parameters.Add(Parameters.GST);
			p.SourceColumn = ColumnNames.GST;
			p.SourceVersion = DataRowVersion.Current;

			p = cmd.Parameters.Add(Parameters.UnitPrice);
			p.SourceColumn = ColumnNames.UnitPrice;
			p.SourceVersion = DataRowVersion.Current;

			p = cmd.Parameters.Add(Parameters.Cost);
			p.SourceColumn = ColumnNames.Cost;
			p.SourceVersion = DataRowVersion.Current;

			p = cmd.Parameters.Add(Parameters.Deleted);
			p.SourceColumn = ColumnNames.Deleted;
			p.SourceVersion = DataRowVersion.Current;

			p = cmd.Parameters.Add(Parameters.LastModifiedDate);
			p.SourceColumn = ColumnNames.LastModifiedDate;
			p.SourceVersion = DataRowVersion.Current;

			p = cmd.Parameters.Add(Parameters.LastModifiedByUser);
			p.SourceColumn = ColumnNames.LastModifiedByUser;
			p.SourceVersion = DataRowVersion.Current;

			p = cmd.Parameters.Add(Parameters.Discount);
			p.SourceColumn = ColumnNames.Discount;
			p.SourceVersion = DataRowVersion.Current;

			p = cmd.Parameters.Add(Parameters.ItemType);
			p.SourceColumn = ColumnNames.ItemType;
			p.SourceVersion = DataRowVersion.Current;

			p = cmd.Parameters.Add(Parameters.BranchID);
			p.SourceColumn = ColumnNames.BranchID;
			p.SourceVersion = DataRowVersion.Current;


			return cmd;
		}
	}
}
